<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-7-21
 * Func   购彩大厅
 */
defined('IN_YuLin') || exit('NO PERMIT!');


$k3 = $db->getall('select * from '.table('lottery').' where ptid = "K3"');
$ssc = $db->getall('select * from '.table('lottery').' where ptid = "SSC"');


$cateTable   = Table('lottery_category');
$lottTable   = Table('lottery');

switch ($a){
    case 'explain':
        // 查看玩法说明
        $lottery_id = NoBadStr($_REQUEST['id']);
        // 彩种玩法说明
        $sql = 'SELECT lott.title, lott.`description` as lott_description, cate.`tags`, cate.`content` as cate_content FROM ' . $lottTable . ' AS lott
                LEFT JOIN ' . $cateTable . ' AS cate
                ON lott.`cate_id` = cate.`id`
                WHERE lott.`id` = ' . $lottery_id;
        $lottInfo   = $db->getrow($sql);
        $page       = 'index/lotteryExplain';
        break;
    default:
        // 查询轮播图
        $getPicSql = "select bn_pic from ".Table('admin_banner')." where bn_type=1 and bn_code = '/cp'";
        $picRes = $db->getall($getPicSql);
        
        // 查询所有彩种类别
        $getCateSql  = 'SELECT * FROM ' . $cateTable . ' WHERE status = 0';
        $cateList    = $db->getall($getCateSql);
        $cateIdKey   = array();
        foreach ($cateList as $ck => $cv){
            $cateIdKey[$cv['id']] = $cv;
        }
        // 查询所有彩种
        $getLottSql  = 'SELECT * FROM ' . $lottTable . ' WHERE status = 1';
        $lottList    = $db->getall($getLottSql);
        $lottCateKey = array();
        // 彩种按照类别Key化
        foreach ($lottList as $k => $v){
            $lottCateKey[$v['cate_id']][] = $v;
        }
        $page       = 'index/lotteryHall';
        break;
}
$tpl->display($page);